<template>
	<view>
		<view class="mt-5" v-if="u_loadmore">
			<u-loadmore status="loading" icon-type="circle" />
		</view>
		<view v-else>
			<view class="" v-if="order_shipments">
				<!-- 地址 -->
				<view class="m-2 bg-white py-3 pl-3 rounded-20">
					<view class="bg-white pb-2 d-flex a-center border-bottom">
						<u-checkbox-group>
							<u-checkbox active-color="#F24F4A" v-model="flag" shape="circle" size="40"></u-checkbox>
						</u-checkbox-group>
						<view class="">
							<view class="d-flex">
								<view class="font-md font-weight">{{order_shipments.consignee}}&nbsp;&nbsp;&nbsp;{{order_shipments.mobile}}</view>
							</view>
							<view class="text-muted pt-1 ">收货地址：{{order_shipments.province+order_shipments.city+order_shipments.district}}&nbsp;{{order_shipments.address}}</view>
						</view>
					</view>
					<view class="d-flex j-center a-center text-danger pt-2" @click="edit_map(order_id)">
						编辑收货地址<u-icon name="arrow-right" color="#f00" size="35"></u-icon>
					</view>
				</view>
				<u-checkbox-group>
					<view  class="m-2 bg-white py-3 pl-3 rounded-20 last_maps">
						<view class="bg-white py-2 d-flex a-center border-bottom last_map" v-for="(item,index) in addressList" :key="index">
							<u-checkbox active-color="#F24F4A"  shape="circle" size="40" @change="check_input(item)"></u-checkbox>
							<view class="">
								<view class="d-flex">
									<view class="font-md font-weight">{{item.consignee}}&nbsp;&nbsp;&nbsp;{{item.mobile}}</view>
								</view>
								<view class="text-muted pt-1">收货地址：{{item.province_name+item.city_name+item.district_name}}&nbsp;{{item.address}}</view>
							</view>
						</view>
					</view>
				</u-checkbox-group>
			</view>
			<view v-else class="d-flex flex-column w-100 a-center j-center h-80">
				<image src="../../static/images/home/icon_no_data.png" mode="" class="icon_no_data"></image>
				<view class="">加载中</view>
			</view>	
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				flag:true,
				order_id:0, // 订单ID
				addressList:"", // 地址列表
				order_shipments:"", // 发货详情列表
				u_loadmore:true, // 加载中
			}
		},
		methods: {
			// 收货地址
			edit_map(order_id){
				uni.navigateTo({
					url:"/pagesA/order/order-edit-map?order_id="+order_id
				})
			},
			// 切换地址
			check_input(item){
				this.$H.post("admin/order/operate/consignee",{
					order_id:this.order_id,
					consignee:item.consignee,
					mobile:item.mobile,
					address_id:item.id
					}).then(res=>{
					uni.navigateBack({
						delta:1
					})
				})
			}
		},
		onLoad(e) {
			this.order_id=e.order_id
			// 订单列表
			this.$H.post("admin/order/consignee/list",{order_id:e.order_id}).then(res=>{
				this.addressList=res.data
				uni.hideToast();
				this.u_loadmore=false 
			}),
			// 订单详情
			this.$H.post("admin/order/operate/shipping/detail",{order_id:e.order_id}).then(res=>{
				this.order_shipments=res.data
				uni.hideToast();
				this.u_loadmore=false 
			})	
		},
		onShow() {
			// 订单详情
			this.$H.post("admin/order/operate/shipping/detail",{order_id:this.order_id}).then(res=>{
				this.order_shipments=res.data
			})
		}
	}
</script>

<style>
	.last_maps .last_map::after{
		border: none;
	}
</style>
